<?php

// $Id$

require_once(TANGRA_MAIN_DIR.'form/gform_ctrl_with_obj.class.php');

require_once('vpage_system_attribute_form.class.php');
require_once('vpage_system_attribute_form_view.class.php');

require_once($WSC->get_site_inc_dir().'modules/tangra_cms/classes/vpage/tcms_vpage_system_attribute_dbc.class.php');
require_once($WSC->get_site_inc_dir().'modules/tangra_cms/classes/vpage/tcms_vpage_dbc.class.php');


class VPage_System_Attribute_Form_Ctrl extends GForm_Ctrl_With_Object {
	protected function create_form() {
		$form = new VPage_System_Attribute_Form();

		$dbc = $this->get_dbc();

//		$form->generate_html();
		return $form;
	}


	protected function create_form_view() {
		$ret = new VPage_System_Attribute_Form_View($this->form);

		return $ret;
	}


	protected function on_good_submit() {
		$ret = true;

		return $ret;
	}


	protected function on_bad_submit() {

//		printbr('lajna');
	}


	protected function create_object() {
		$object = new TCMS_VPage_System_Attribute_DBC();

		return $object;
	}


	protected function transfer_obj2form() {
		$object = $this->get_object();
		$form = $this->get_form();

		$form->set_field_value('value', $object->get_value());
	}


	protected function transfer_form2obj() {
		$object = $this->get_object();
		$form = $this->get_form();

		$object->set_value($form->get_field_value('value'));

		if (!$object->get_id()) {
			$object->set_t_sa_id($this->get_permanent_external_param('vpt_sa'));
			$object->set_vpage($this->get_permanent_external_param('vpage'));
		}
	}


	protected function on_trans_ending(DB_Connection $dbc) {
		$object = $this->get_object();
		TCMS_VPage_DBC::update_last_modified($dbc, $object->get_vpage(), $this->get_permanent_external_param('user'));
	}
}